/** 
 * Token.java
 * @author Lex
 * 2007-8-17 ����01:11:51
 */
package fun.parser.lexer;

/**
 * Ϊ�˼���� Token �����Ϊ���ɱ��
 */
public class Token {
	private int lineNumber = 0;
	private int offset = 0;
	private String image = "";
	// =======================
	private TokenType tokenType = null;

	public Token(String image, TokenType type, int line, int offset) {
		this.image = image;
		this.tokenType = type;
		this.lineNumber = line;
		this.offset = offset;
	}

	public int getLineNumber() {
		return this.lineNumber;
	}

	public int getOffset() {
		return this.offset;
	}

	public String getImage() {
		return this.image;
	}

	public TokenType getTokenType() {
		return this.tokenType;
	}

	public String toString() {
		StringBuilder buffer = new StringBuilder(image);
		buffer.append(' ').append(':').append(' ');
		buffer.append(tokenType.name());
		buffer.append('[').append(lineNumber).append(',').append(' ');
		buffer.append(offset).append(']');
		return buffer.toString();
	}
}
